package model;

/**
 * The NotCached class is a State without any cached fields.
 * 
 * @author hfi411pi
 *
 */
public class NotCached  extends ComponentState{


	/**
	 * Factory method for creating a NotCached state.
	 * @param master is the ComponentCommon of this state.
	 * @return the created state.
	 */
	public static NotCached create(final ComponentCommon master){
		return new NotCached(master);
	}
	
	/**
	 * Constructor of NotCached.
	 * @param master is the ComponentCommon of this state.
	 */
	private NotCached(final ComponentCommon master) {
		super(master);
	}

	@Override
	public MaterialList getMaterialList() {
		final MaterialList materials = this.getMaster().calculateNewMaterialList();
		this.getMaster().setState(MaterialListCached.create(this.getMaster(), materials));
		return materials;
	}

	@Override
	public int getOverallPrice() {
		final MaterialList materials = this.getMaster().getMaterialList();
		final int overallPrice = this.getMaster().calculateNewOverallPrice();
		this.getMaster().setState(MaterialListPriceCached.create(this.getMaster(), materials, overallPrice));
		return overallPrice;
	}

	@Override
	protected void handlePriceChangedEvent(final PriceChangedEvent priceChangedEvent) {
		
	}

	@Override
	protected void handleStructureChangedEvent(
			final StructureChangedEvent structureChangedEvent) {
		
	}
	
	@Override
	public String toString(){
		return PartsListConstants.notCached;
	}
}
